package cn.growthgate.fgo.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;

import cn.growthgate.fgo.entity.Item;
import cn.growthgate.fgo.entity.MyServant;
import cn.growthgate.fgo.entity.Servant;
import cn.growthgate.fgo.entity.enums.ServantItemType;

/**
 * <p>
 * 我的从者 Mapper 接口
 * </p>
 *
 * @author GrowthGate
 * @since 2019-05-29
 */
public interface MyServantMapper extends BaseMapper<MyServant> {

	@Select("select * from t_data_servant where id = #{servantId}")
	public Servant getServant(MyServant myServant);

	public List<MyServant> selectJoinServant(RowBounds rowBounds, @Param("ew") Wrapper<MyServant> wrapper);

	@Select("select * from t_data_item where type in (0, 1, 2)")
	public List<Item> selectAllItem();

	@MapKey("itemId")
	@Select("select itemId, sum(number) number from t_data_servant_item"
			+ " where servantId = #{servantId} and type = #{type} and level >= #{from} and level <= #{to}"
			+ " group by itemId")
	public Map<Long, Map<String, Object>> getServantItemNumber(@Param("servantId") long servantId,
			@Param("type") ServantItemType type, @Param("from") int from, @Param("to") int to);

}
